import request from "@/utils/request";
import { AxiosPromise } from "axios";
import {
  FestivalTypeQuery,
  FestivalTypePageResult,
  FestivalTypeForm,
  CouponTypeQuery,
  CouponPageResult,
} from "./types";

/**
 * 获取节日列表
 *
 * @param queryParams
 */
export function getFestivalTypePage(
  queryParams: FestivalTypeQuery
): AxiosPromise<FestivalTypePageResult> {
  return request({
    url: "/api/v1/activity/festival/page",
    method: "get",
    params: queryParams,
  });
}

/**
 * 新增节日营销活动
 *
 * @param data
 */
export function addFestableActivity(data: FestivalTypeForm) {
  return request({
    url: "/api/v1/activity/festival",
    method: "post",
    data: data,
  });
}

/**
 * 编辑节日营销活动
 *
 * @param data
 */
export function updateFestableActivity(data: FestivalTypeForm) {
  return request({
    url: "/api/v1/activity/festival",
    method: "put",
    data: data,
  });
}

/**
 * 根据id获取优惠卷活动详细信息接口
 *
 * @param id
 */
export function getActivityInfoById(
  id: number
): AxiosPromise<FestivalTypeForm> {
  return request({
    url: `/api/v1/activity/festival/${id}`,
    method: "get",
  });
}

/**
 * 获取优惠卷列表接口
 *
 * @param queryParams
 */
export function getCouponList(
  queryParams: CouponTypeQuery
): AxiosPromise<CouponPageResult> {
  return request({
    url: "/api/v1/coupon/page",
    method: "get",
    params: queryParams,
  });
}
